<template>
  <div>
    <NavMenu></NavMenu>
    <el-table :data="tableData" stripe style="width: 100%" @cell-click="cellClick">
      <el-table-column prop="name" label="公司名称" width="180">
      </el-table-column>
      <el-table-column prop="type" label="类型" width="180">
      </el-table-column>
      <el-table-column prop="address" label="地址" width="300">
      </el-table-column>
      <el-table-column prop="details" label="详情">
        <template slot-scope="scope">
          <el-button type="text" @click="goToDetail">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import NavMenu from "@/components/NavMenu";
import ajax from "@/components/ajax";
export default {
  name: "Info",
  data() {
    return {
      tableData: []
    };
  },
  methods: {
    goToDetail() {
      this.$router.push({
        path: "/JobInfo"
      });
    },
    cellClick(row, column, cell, event) {
      if (column.label === "详情") {
        this.$router.push({
          query: {
            id: row._id
          }
        });
      }
    }
  },
  beforeMount: function() {
    const that = this;
    ajax({
      method: "get",
      url: "http://127.0.0.1:3000/list",
      success: function(res) {
        // console.log(res);
        that.tableData = res;
      }
    });
  },
  components: {
    NavMenu
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /* margin-top: 60px; */
}
</style>
